<?php
/**
 * Created by PhpStorm.
 * User: 仙女大人
 * Date: 2019/5/11
 * Time: 17:30
 */

namespace app\admin\model;
use think\Model;

class User extends Model
{
    // 设置数据表（不含前缀）
    protected $name = 'form';

    // 性别读取器
    protected function getSexAttr($value)
    {
        $sex = [''=>'',1 => '女',0 => '男'];
        return $sex[$value];
    }

    //  爱好读取器
    protected  function getLikeAttr($value)
    {
        $value = explode(',',$value);
        $like = [''=>'','write'=>'阅读','dai'=>'发呆','read'=>'写作'];
        $yy = '';
        foreach($value as $v)
        {
            $yy .= $like[$v].',';
        }
        return $yy;
    }

    //  城市读取器
    protected  function getCityAttr($value)
    {
        $city = [''=>'','0'=>'北京','1'=>'上海','2'=>'广州','3'=>'深圳','4'=>'杭州'];
        return $city[$value];
    }
}